import { defineStore } from 'pinia'

const THEME_KEY = 'theme-mode'

export const useThemeStore = defineStore('theme', {
  state: () => ({
    mode: localStorage.getItem(THEME_KEY) || 'light' // 'light' or 'dark'
  }),
  actions: {
    toggleTheme() {
      this.mode = this.mode === 'light' ? 'dark' : 'light'
      localStorage.setItem(THEME_KEY, this.mode)
      document.documentElement.setAttribute('data-theme', this.mode)
    },
    setTheme(mode) {
      this.mode = mode
      localStorage.setItem(THEME_KEY, mode)
      document.documentElement.setAttribute('data-theme', mode)
    }
  }
}) 